﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;


namespace AnakraEditor
{
    class Scene
    {
        public List<Item> items;
        public List<string> texturePaths;
        public SceneFile sceneFile;

        public Scene()
        {
            items = new List<Item>();
            texturePaths = new List<String>();
        }
        public void Save(String path) {
            sceneFile = new SceneFile();
            sceneFile.items = items;
            sceneFile.texturePaths = texturePaths;
            XmlSerializer serializer = new XmlSerializer(typeof(SceneFile));
            TextWriter file = new StreamWriter(path);
            serializer.Serialize(file, sceneFile);
            file.Close();
        }
        public void Load(String path)
        {
            XmlSerializer deserializer = new XmlSerializer(typeof(SceneFile));
            TextReader fileLoaded = new StreamReader(path);
            sceneFile = (SceneFile)deserializer.Deserialize(fileLoaded);
            items = sceneFile.items;
            texturePaths = sceneFile.texturePaths;
            fileLoaded.Close();
        }
    }
    public struct position
    {
         public float x;
         public float y;
    }
    public struct Item
    {
        public position position;
        public float rotation;
        public string id;
        public int texture;
        public float depth;
        public float scale;
        public bool visible;
        public string attributes;
    }
    public struct SceneFile
    {
        public List<Item> items;
        public List<String> texturePaths;
    }
}
